﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DownTime : EventManager
{
    private static DownTime instance;
    public static DownTime GetInstance()
    {
        return instance;
    }
    void Awake()
    {
        instance = this;
    }

    public Text downTimeTex;
    private double timer;

    public void StartDownTime(int num)
    {
        timer = num;
        isDownTime = true;
    }

    public void StopDownTime()
    {
        SetText(downTimeTex, "");
        timer = 0;
        isDownTime = false;
    }

    private bool isDownTime;
    void Update () {

        if (isDownTime)
        {
            if (timer > 0)
            {
                timer -= Time.deltaTime;
            }
            else
            {
                timer = 0;
            }

            if ((Math.Floor(timer)).ToString() != downTimeTex.text)
            {
                SetText(downTimeTex, (Math.Floor(timer)).ToString());
            }
        }
	}

    public override void InformationSetting()
    {
    }
}
